package com.yun.blog.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yun.blog.bean.User;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;


public interface UserService extends IService<User> {
    int updateLastLoginTimeByUserId(Integer userId);

    User getOneByUsernameAndPassword(String username, String password);

    <P extends IPage<User>> P customPage(P page, String searchText);

    User getByUserUsername(@Param("userUsername") String userUsername);

    /**
     * 重写通过ids获取用户信息列表
     * @author yun
     * @date 2023/6/20 下午10:48
     * @param idList
     * @return List<User>
     */
    @Override
    default List<User> listByIds(Collection<? extends Serializable> idList) {
        List<User> users = IService.super.listByIds(idList);
        // 隐藏密码等数据
        users.forEach(user -> {
            user.setUserPassword("");
            user.setRefreshToken("");
            user.setAccessToken("");
        });
        return users;
    }
}
